<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 15-8-19
 * Time: ����10:27
 */
//echo 'success';
$txt = file_get_contents('php://input');


logfile(date('Y-d-m H:i:s').$txt,'ticket.txt');

//$txt = '{"VerifyCode":"b5c4cadfd06ac2432bdbe585b55c472d","Order16U":"2080376","ActionTime":"2015-08-25 16:51:03","OrderCall":"","Tnumber":"2","OrderState":1}';
$response_array = json_decode($txt,true);

$order = $response_array['Order16U'];
if($order!=null){
    include '/var/www/html/new/d/module/qkxproject/api/shenyouhuaxia/syhx.class.php';
     $syhx = new ShenYouHuaXia();
     $response = $syhx->takeTicket($order);
    if($response==101){
        logfile(date('Y-d-m H:i:s').$response,'ticket.txt');
        echo 101;
    }else{
        $str="update all_api_order set oStatus=1,handleStatus=0 where pftOrder='".$_REQUEST['Order16U']."' limit 1";
        $GLOBALS['le']->query($str);
        echo 100;
    }
}



       function logfile($txt, $path)
       {
           $fp = fopen($path, "a");
           flock($fp, LOCK_EX);
           fwrite($fp, $txt . "\n");
           flock($fp, LOCK_UN);
           fclose($fp);
       }